CSharpTest.Net
DebugSetOutput Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : DebugSetOutput Method

output

Glossary Item Box

Sets a text writter that the entire btree will be dumped to after every read/write/seek operation. The format is a single line of text in abbreviated form: {k1{k1,k2,k3},k4{k4,k5}}

Syntax

Visual Basic (Declaration) 
Public Sub DebugSetOutput( _
   ByVal output As TextWriter _
) 
C# 
public void DebugSetOutput( 
   TextWriter output
)

Parameters

output

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C#Copy Code
var options = Options;
options.BTreeOrder = 4;
using (BPlusTree<int, string> data = new BPlusTree<int,string>(options))
{
    data.EnableCount();
    
    data.DebugSetOutput(new StringWriter());
    data.DebugSetValidateOnCheckpoint(true);

    for (int id = 0; id < 10; id++)
        data.Add(id, id.ToString());

    using (IEnumerator<KeyValuePair<int, string>> enu = data.GetEnumerator())
    {
        Assert.IsTrue(enu.MoveNext());
        Assert.AreEqual(0, enu.Current.Key);

        for (int id = 2; id < 10; id++)
            Assert.IsTrue(data.Remove(id));
        for (int id = 6; id < 11; id++)
            data.Add(id, id.ToString());

        Assert.IsTrue(enu.MoveNext());
        Assert.AreEqual(1, enu.Current.Key);
        Assert.IsTrue(enu.MoveNext());
        Assert.AreEqual(6, enu.Current.Key);
        Assert.IsTrue(enu.MoveNext());
        Assert.AreEqual(7, enu.Current.Key);
        Assert.IsTrue(data.Remove(8));
        Assert.IsTrue(data.Remove(9));
        Assert.IsTrue(data.Remove(10));
        data.Add(11, 11.ToString());
        Assert.IsTrue(enu.MoveNext());
        Assert.AreEqual(11, enu.Current.Key);
        Assert.IsTrue(false == enu.MoveNext());
    }
    data.Clear();
}
VB.NETCopy Code
Dim options As var = Options
options.BTreeOrder = 4
Using data As New BPlusTree(Of Integer, String)(options)
    data.EnableCount()

    data.DebugSetOutput(New StringWriter())
    data.DebugSetValidateOnCheckpoint(True)

    Dim id As Integer = 0
    While id < 10
        data.Add(id, id.ToString())
        System.Math.Max(System.Threading.Interlocked.Increment(id),id - 1)
    End While

    Using enu As IEnumerator(Of KeyValuePair(Of Integer, String)) = data.GetEnumerator()
        Assert.IsTrue(enu.MoveNext())
        Assert.AreEqual(0, enu.Current.Key)

        Dim id As Integer = 2
        While id < 10
            Assert.IsTrue(data.Remove(id))
            System.Math.Max(System.Threading.Interlocked.Increment(id),id - 1)
        End While
        Dim id As Integer = 6
        While id < 11
            data.Add(id, id.ToString())
            System.Math.Max(System.Threading.Interlocked.Increment(id),id - 1)
        End While

        Assert.IsTrue(enu.MoveNext())
        Assert.AreEqual(1, enu.Current.Key)
        Assert.IsTrue(enu.MoveNext())
        Assert.AreEqual(6, enu.Current.Key)
        Assert.IsTrue(enu.MoveNext())
        Assert.AreEqual(7, enu.Current.Key)
        Assert.IsTrue(data.Remove(8))
        Assert.IsTrue(data.Remove(9))
        Assert.IsTrue(data.Remove(10))
        data.Add(11, 11.ToString())
        Assert.IsTrue(enu.MoveNext())
        Assert.AreEqual(11, enu.Current.Key)
        Assert.IsTrue(False = enu.MoveNext())
    End Using
    data.Clear()
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys